//
//  PIReport.m
//  playin
//
//  Created by playin on 2019/5/6.
//  Copyright © 2019 A. All rights reserved.
//

#import "PIReport.h"
#import "PIUtil.h"
#import "PIHttpManager.h"

@implementation PIReport

+ (void)reportWithDeviceID:(NSString *)deviceID token:(NSString *)token idrCount:(NSNumber *)count gesCount:(NSNumber *)gesCount{
    
    if (![PIUtil validStr:deviceID]) {
        NSLog(@"[PIReport] init error: invalid key");

        return;
    }
    NSString *urlStr = [NSString stringWithFormat:@"http://3.112.73.171/adtiming/device/report"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:deviceID forKey:@"device_id"];
    [params setValue:token forKey:@"token"];
    [params setValue:@"ios" forKey:@"source"];
    [params setValue:count forKey:@"idr_count"];
    [params setValue:gesCount forKey:@"ges_count"];
    [PIHttpManager post:urlStr params:params success:^(NSDictionary * _Nonnull result) {
        NSLog(@"[PIReport] endplay report result: %@", result);
    } failure:^(NSDictionary * _Nonnull error) {
        NSLog(@"[PIReport] endplay report error: %@", error);
    }];
}

@end
